home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / lib / rpm-3.0.6 / brp-compress next >
Encoding:
Text File  |  2001-04-06  |  1.3 KB  |  56 lines

  1. #!/bin/sh
  2.  
  3. # If using normal root, avoid changing anything.
  4. if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
  5.     exit 0
  6. fi
  7.  
  8. cd $RPM_BUILD_ROOT
  9.  
  10. # Compress man pages
  11. COMPRESS="gzip -9"
  12. COMPRESS_EXT=.gz
  13.  
  14. for d in ./usr/man/man* ./usr/man/*/man* ./usr/info \
  15.     ./usr/share/man/man* ./usr/share/man/*/man* ./usr/share/info \
  16.     ./usr/kerberos/man ./usr/X11R6/man/man* ./usr/lib/perl5/man/man*
  17. do
  18.     [ -d $d ] || continue
  19.     for f in `find $d -type f`
  20.     do
  21.         [ -f "$f" ] || continue
  22.     [ "`basename $f`" = "dir" ] && continue
  23.  
  24.     case "$f" in
  25.      *.Z) gunzip $f; b=`echo $f | sed -e 's/\.Z$//'`;;
  26.      *.gz) gunzip $f; b=`echo $f | sed -e 's/\.gz$//'`;;
  27.      *.bz2) bunzip2 $f; b=`echo $f | sed -e 's/\.bz2$//'`;;
  28.      *) b=$f;;
  29.     esac
  30.  
  31.     $COMPRESS $b 2>/dev/null || {
  32.         inode=`ls -i $b | awk '{ print $1 }'`
  33.         others=`find $d -type f -inum $inode`
  34.         if [ -n "$others" ]; then
  35.         for afile in $others ; do
  36.             [ "$afile" != "$b" ] && rm -f $afile
  37.         done
  38.         $COMPRESS -f $b
  39.         for afile in $others ; do
  40.             [ "$afile" != "$b" ] && ln $b$COMPRESS_EXT $afile$COMPRESS_EXT
  41.         done
  42.         else
  43.         $COMPRESS -f $b
  44.         fi
  45.     }
  46.     done
  47.  
  48.     for f in `find $d -type l`
  49.     do
  50.     l=`ls -l $f | awk '{ print $11 }' | sed -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'`
  51.     rm -f $f
  52.     b=`echo $f | sed -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'`
  53.     ln -sf $l$COMPRESS_EXT $b$COMPRESS_EXT
  54.     done
  55. done
  56.